package com.springboot.demo.design.pattern.plugin.impl;

import com.alibaba.fastjson.JSONObject;
import com.springboot.demo.design.pattern.instruction.Instruction;
import com.springboot.demo.design.pattern.plugin.AfterPlugin;
import java.lang.reflect.Method;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * 用户后置插件
 *
 * @author supu
 * @date 2019-03-27 14:34
 **/
@Component
@Log4j2
public class UserLogAfterPlugin implements AfterPlugin {
    @Override
    public void interceptor(Object proxy, Method method, Object[] args, Object result, Throwable throwable) {
        Instruction instruction = (Instruction) args[0];
        log.warn("formNo:{} 运行结果：{}", instruction.getForm().getFormNo(), JSONObject.toJSONString(instruction.getForm().getResult()));
    }
}
